﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Core.Interfaces;
using Core.Interfaces.IDAO;
using Core.Unity;
using Microsoft.Practices.Unity;

namespace Core.Reports
{
    public partial class SecondReport : Form
    {
        private List<IAction> actions; 
        public SecondReport()
        {
            InitializeComponent();
            actions = ResolverContainer.Resolver.Resolve<IActionDAO>().GetAll(false);
            iActionBindingSource.DataSource = actions;
        }

        private void button1_Click(object sender, EventArgs e)
        {

          
            var connection = new SqlConnection("Data Source=" + @"НИКОЛАЙ-ПК\SQLEXPRESS" + ";Initial Catalog=" + "buildings" + ";Integrated Security=True");
            SqlDataAdapter adapter_action   = new SqlDataAdapter(string.Format("SELECT * FROM dbo.action where id_action ={0}",((IAction)iActionBindingSource.Current).ActionId), connection);
            SqlDataAdapter adapter_owned_buildings = new SqlDataAdapter(string.Format("SELECT * FROM dbo.owned_building where id_action ={0}",((IAction)iActionBindingSource.Current).ActionId), connection);
            SqlDataAdapter adapter_building_action = new SqlDataAdapter("SELECT * FROM dbo.building_action", connection);
            adapter_action.Fill(cursDataSet1, "action");
            adapter_owned_buildings.Fill(cursDataSet1, "owned_building");
            adapter_building_action.Fill(cursDataSet1, "building_action");
            report1.Show();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
